let dataMgr = require("./DataMgr");

cc.Class({
    extends: cc.Component,

    properties: {
        audio: cc.AudioClip,
        playerPre: [cc.Prefab],
    },



    onLoad() {
        //开启物理系统
        cc.director.getPhysicsManager().enabled = true;
        //设置背景音乐
        cc.audioEngine.playMusic(this.audio, true);
        //创建玩家
        this.createPlayer();
    },

    start() {

    },

    update(dt) { },

    //创建玩家
    createPlayer() {
        let roleIndex = dataMgr.getInstance().getData("roleIndex");
        this.playerNode = cc.instantiate(this.playerPre[roleIndex]);
        this.playerNode.parent = this.node;
    }
});
